<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>表单</title>
  <link rel="stylesheet" type="text/css" href="../js/layer/css/layui.css">
  <link rel="stylesheet" type="text/css" href="../dialog/css/materialdesignicons.min.css">
  <link rel="stylesheet" type="text/css" href="../dialog/css/bootstrap.min.css">
  <link rel="stylesheet" type="text/css" href="../dialog/css/animate.min.css">
  <link rel="stylesheet" type="text/css" href="../dialog/css/style.min.css">
  <script type="text/javascript" charset="utf-8" src="../js/layer/module/ext/ueditor/ueditor.config.js"></script>
  <script type="text/javascript" charset="utf-8" src="../js/layer/module/ext/ueditor/_examples/editor_api.js"></script>
  <link rel="stylesheet" type="text/css" href="../css/admin.css">
  <meta http-equiv="pragma" content="no-cache">
  <meta http-equiv="cache-control" content="no-cache">
  <meta http-equiv="expires" content="0">
</head>
<body>
<form  class="layui-form">
<div id="view">

  <div class="row">

    <div class="col-lg-12">
      <div class="card">



        <!---验证还是走lay-->
        <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
          <ul class="layui-tab-title" id="layui-tab-ul" style="margin-left: 10px;text-align: center;">
            {{#  arr_foreach(d, function(index, item){ }}
            {{index = parseInt(index)}}
              <li id="layertab{{index}}" data-index="{{index}}" data-table="{{item.step}}"  class="{{#  if(index == 0){ }}layui-this{{#  } }}">{{item.title}}</li>
            {{#  }); }}
          </ul>

          <div class="layui-tab-content">

            {{#  arr_foreach(d, function(index, item){ }}
            <!----分步骤表单--->
            <div class="layui-tab-item {{#  if(index == 0){ }}layui-show{{#  } }}">
              <div class="col-md-12">
                {{#  arr_foreach(item.schema, function(k, v){ }}
                {{#  if(v.input_type == 'hidden'){ }}
                <input type="{{v.input_type}}" class="form-control" placeholder="请输入{{v.title}}" name="{{item.step}}[{{v.field}}]" id="step{{item.step}}--{{v.field}}" value="{{hiddenVal(v.default)}}">

                {{#  }else if(v.input_type == 'tag'){ }}

                <div class="form-group">
                  <label for="step{{item.step}}--{{v.field}}"><b class="text-pink">{{#  if(v.null == 'no'){ }}*{{#  } }}</b>{{v.title}}</label>
                  <div class="clearfix">
                    <div class="fairy-tag-container">
                      <input id="step{{item.step}}--{{v.field}}-tag" type="text" class="inputTag fairy-tag-input tag2">
                    </div>

                    <input class="inputTagVal" name="{{item.step}}[{{v.field}}]" type="hidden" value="">

                  </div>
                </div>

                {{#  }else if(v.input_type == 'cascader'){ }}

                <div class="form-group">
                  <label for="step{{item.step}}--{{v.field}}"><b class="text-pink">{{#  if(v.null == 'no'){ }}*{{#  } }}</b>{{v.title}}</label>
                  <div class="clearfix">
                    <div class="cascader-prop" style="display: none;">
                      {{json_encode(v.value)}}
                    </div>
                    <input type="text" data-menuid="{{v.value_menu}}" class="form-control inputCascader" placeholder=""  name="{{item.step}}[{{v.field}}]" id="step{{item.step}}--{{v.field}}" value="0">
                  </div>
                </div>


                {{#  }else if(v.input_type == 'select'){ }}
                <div class="form-group">
                  <label for="step{{item.step}}--{{v.field}}"><b class="text-pink">{{#  if(v.null == 'no'){ }}*{{#  } }}</b>{{v.title}}</label>
                  <div class="form-controls">
                    <select lay-ignore class="form-control" name="{{item.step}}[{{v.field}}]">
                      <option value="">请选择</option>
                      {{#  arr_foreach(v.value, function(k1, v1){ }}
                      {{#  if(k1 == v.default){ }}
                      <option value="{{k1}}" selected="">{{v1}}</option>
                      {{# }else{ }}
                      <option value="{{k1}}">{{v1}}</option>
                      {{#  } }}
                      {{#  }); }}
                    </select>
                  </div>
                </div>

                {{#  }else if(v.input_type == 'radio'){ }}
                <div class="form-group">
                  <label for="step{{item.step}}--{{v.field}}"><b class="text-pink">{{#  if(v.null == 'no'){ }}*{{#  } }}</b>{{v.title}}</label>
                  <div class="clearfix">
                    {{#  arr_foreach(v.value, function(k1, v1){ }}
                    <div class="custom-control custom-radio custom-control-inline">
                      {{#  if(k1 == v.default){ }}
                      <input checked lay-ignore type="radio" id="step{{item.step}}--{{v.field}}--{{k1}}" name="{{item.step}}[{{v.field}}]" class="custom-control-input" value="{{k1}}">
                      {{# }else{ }}
                      <input lay-ignore type="radio" id="step{{item.step}}--{{v.field}}--{{k1}}" name="{{item.step}}[{{v.field}}]" class="custom-control-input" value="{{k1}}">
                      {{#  } }}

                      <label class="custom-control-label" for="step{{item.step}}--{{v.field}}--{{k1}}">{{v1}}</label>
                    </div>
                    {{#  }); }}
                  </div>
                </div>

                {{#  }else if(v.input_type == 'checkbox'){ }}
                <div class="form-group">
                  <label for="step{{item.step}}--{{v.field}}"><b class="text-pink">{{#  if(v.null == 'no'){ }}*{{#  } }}</b>{{v.title}}</label>
                  <div class="clearfix">
                    {{#  arr_foreach(v.value, function(k1, v1){ }}
                    <div class="custom-control custom-checkbox custom-control-inline">
                      <input lay-ignore type="checkbox" id="step{{item.step}}--{{v.field}}--{{k1}}" name="{{item.step}}[{{v.field}}][]" class="custom-control-input" value="{{k1}}">
                      <label class="custom-control-label" for="step{{item.step}}--{{v.field}}--{{k1}}">{{v1}}</label>
                    </div>
                    {{#  }); }}
                  </div>
                </div>

                {{#  }else if(v.input_type == 'radios'){ }}
                <div class="form-group">
                  <label for="step{{item.step}}--{{v.field}}"><b class="text-pink">{{#  if(v.null == 'no'){ }}*{{#  } }}</b>{{v.title}}</label>
                  <div class="clearfix">
                    <div class="xm-select-demo inputRadios" id="step{{item.step}}--{{v.field}}-div"  data-menuid="{{v.value_menu}}"></div>
                    <input type="hidden" placeholder="请输入{{v.title}}" name="{{item.step}}[{{v.field}}]" id="step{{item.step}}--{{v.field}}" value=''>
                  </div>
                </div>

                {{#  }else if(v.input_type == 'checkboxs'){ }}
                <div class="form-group">
                  <label for="step{{item.step}}--{{v.field}}"><b class="text-pink">{{#  if(v.null == 'no'){ }}*{{#  } }}</b>{{v.title}}</label>
                  <div class="clearfix">
                    <div class="xm-select-demo inputCheckboxs" id="step{{item.step}}--{{v.field}}-div"  data-menuid="{{v.value_menu}}"></div>
                    <input type="hidden" placeholder="请输入{{v.title}}" name="{{item.step}}[{{v.field}}]" id="step{{item.step}}--{{v.field}}" value=''>
                  </div>
                </div>

                {{#  }else if(v.input_type == 'radiowindow'){ }}
                <div class="form-group">
                  <label for="step{{item.step}}--{{v.field}}"><b class="text-pink">{{#  if(v.null == 'no'){ }}*{{#  } }}</b>{{v.title}}</label>
                  <div class="clearfix">
                    <div class="xm-select-demo inputRadios" id="step{{item.step}}--{{v.field}}-div"  data-menuid="{{v.value_menu}}"></div>
                    <input type="hidden" placeholder="请输入{{v.title}}" name="{{item.step}}[{{v.field}}]" id="step{{item.step}}--{{v.field}}" value=''>
                  </div>
                </div>
                {{#  }else if(v.input_type == 'checkboxwindow'){ }}
                <div class="form-group">
                  <label for="step{{item.step}}--{{v.field}}"><b class="text-pink">{{#  if(v.null == 'no'){ }}*{{#  } }}</b>{{v.title}}</label>
                  <div class="clearfix">
                    <div class="xm-select-demo inputCheckboxs" id="step{{item.step}}--{{v.field}}-div"  data-menuid="{{v.value_menu}}"></div>
                    <input type="hidden" placeholder="请输入{{v.title}}" name="{{item.step}}[{{v.field}}]" id="step{{item.step}}--{{v.field}}" value=''>
                  </div>
                </div>

                {{#  }else if(v.input_type == 'textarea'){ }}
                <div class="form-group">
                  <label for="step{{item.step}}--{{v.field}}"><b class="text-pink">{{#  if(v.null == 'no'){ }}*{{#  } }}</b>{{v.title}}</label>
                  <div class="clearfix">
                    <textarea class="form-control inputTextarea" name="{{item.step}}[{{v.field}}]" id="step{{item.step}}--{{v.field}}"></textarea>
                  </div>
                </div>

                {{#  }else if(v.input_type == 'date'){ }}
                <div class="form-group">
                  <label for="step{{item.step}}--{{v.field}}"><b class="text-pink">{{#  if(v.null == 'no'){ }}*{{#  } }}</b>{{v.title}}</label>
                  <input type="text" class="form-control inputDate" placeholder="请输入{{v.title}}" name="{{item.step}}[{{v.field}}]" id="step{{item.step}}--{{v.field}}" value="">

                </div>

                {{#  }else if(v.input_type == 'time'){ }}
                <div class="form-group">
                  <label for="step{{item.step}}--{{v.field}}"><b class="text-pink">{{#  if(v.null == 'no'){ }}*{{#  } }}</b>{{v.title}}</label>
                  <input type="text" class="form-control inputTime" placeholder="请输入{{v.title}}" name="{{item.step}}[{{v.field}}]" id="step{{item.step}}--{{v.field}}" value="">

                </div>

                {{#  }else if(v.input_type == 'timerange'){ }}
                <div class="form-group">
                  <label for="step{{item.step}}--{{v.field}}"><b class="text-pink">{{#  if(v.null == 'no'){ }}*{{#  } }}</b>{{v.title}}</label>
                  <input type="text" class="form-control inputTimerange" placeholder="请输入{{v.title}}" name="{{item.step}}[{{v.field}}]" id="step{{item.step}}--{{v.field}}" value="">

                </div>

                {{#  }else if(v.input_type == 'image'){ }}
                <div class="form-group">
                  <label for="step{{item.step}}--{{v.field}}"><b class="text-pink">{{#  if(v.null == 'no'){ }}*{{#  } }}</b>{{v.title}}</label>
                  <div class="form-controls">
                    <input type="hidden" class="form-control inputImage" placeholder="请输入{{v.title}}" name="{{item.step}}[{{v.field}}]" id="step{{item.step}}--{{v.field}}" value='{{=v.default}}'>
                  </div>
                </div>

                {{#  }else if(v.input_type == 'images'){ }}
                <div class="form-group">
                  <label for="step{{item.step}}--{{v.field}}"><b class="text-pink">{{#  if(v.null == 'no'){ }}*{{#  } }}</b>{{v.title}}</label>
                  <div class="form-controls">
                    <input type="hidden" class="form-control inputImages" placeholder="请输入{{v.title}}" name="{{item.step}}[{{v.field}}]" id="step{{item.step}}--{{v.field}}" value='{{=v.default}}'>
                  </div>
                </div>

                {{#  }else if(v.input_type == 'audio'){ }}

                <div class="form-group">
                  <label for="step{{item.step}}--{{v.field}}"><b class="text-pink">{{#  if(v.null == 'no'){ }}*{{#  } }}</b>{{v.title}}</label>
                  <div class="form-controls">
                    <input type="hidden" class="form-control inputAudio" placeholder="请输入{{v.title}}" name="{{item.step}}[{{v.field}}]" id="step{{item.step}}--{{v.field}}" value='{{=v.default}}'>
                  </div>
                </div>

                {{#  }else if(v.input_type == 'audios'){ }}

                <div class="form-group">
                  <label for="step{{item.step}}--{{v.field}}"><b class="text-pink">{{#  if(v.null == 'no'){ }}*{{#  } }}</b>{{v.title}}</label>
                  <div class="form-controls">
                    <input type="hidden" class="form-control inputAudios" placeholder="请输入{{v.title}}" name="{{item.step}}[{{v.field}}]" id="step{{item.step}}--{{v.field}}" value='{{=v.default}}'>
                  </div>
                </div>

                {{#  }else if(v.input_type == 'video'){ }}

                <div class="form-group">
                  <label for="step{{item.step}}--{{v.field}}"><b class="text-pink">{{#  if(v.null == 'no'){ }}*{{#  } }}</b>{{v.title}}</label>
                  <div class="form-controls">
                    <input type="hidden" class="form-control inputVideo" placeholder="请输入{{v.title}}" name="{{item.step}}[{{v.field}}]" id="step{{item.step}}--{{v.field}}" value='{{=v.default}}'>
                  </div>
                </div>

                {{#  }else if(v.input_type == 'videos'){ }}
                <div class="form-group">
                  <label for="step{{item.step}}--{{v.field}}"><b class="text-pink">{{#  if(v.null == 'no'){ }}*{{#  } }}</b>{{v.title}}</label>
                  <div class="form-controls">
                    <input type="hidden" class="form-control inputVideos" placeholder="请输入{{v.title}}" name="{{item.step}}[{{v.field}}]" id="step{{item.step}}--{{v.field}}" value='{{=v.default}}'>
                  </div>
                </div>

                {{#  }else if(v.input_type == 'document'){ }}

                <div class="form-group">
                  <label for="step{{item.step}}--{{v.field}}"><b class="text-pink">{{#  if(v.null == 'no'){ }}*{{#  } }}</b>{{v.title}}</label>
                  <div class="form-controls">
                    <input type="hidden" class="form-control inputDocument" placeholder="请输入{{v.title}}" name="{{item.step}}[{{v.field}}]" id="step{{item.step}}--{{v.field}}" value='{{=v.default}}'>
                  </div>
                </div>

                {{#  }else if(v.input_type == 'documents'){ }}

                <div class="form-group">
                  <label for="step{{item.step}}--{{v.field}}"><b class="text-pink">{{#  if(v.null == 'no'){ }}*{{#  } }}</b>{{v.title}}</label>
                  <div class="form-controls">
                    <input type="hidden" class="form-control inputDocuments" placeholder="请输入{{v.title}}" name="{{item.step}}[{{v.field}}]" id="step{{item.step}}--{{v.field}}" value='{{=v.default}}'>
                  </div>
                </div>

                {{#  }else if(v.input_type == 'baidueditor'){ }}
                <div class="form-group">
                  <label for="step{{item.step}}--{{v.field}}"><b class="text-pink">{{#  if(v.null == 'no'){ }}*{{#  } }}</b>{{v.title}}</label>
                  <div class="clearfix">
                    <textarea style="width:100%;height:400px;" class="layui-textarea inputBaidueditor" name="{{item.step}}[{{v.field}}]" id="step{{item.step}}--{{v.field}}"></textarea>
                  </div>
                </div>
                {{#  }else if(v.input_type == 'jsoneditor'){ }}
                <div class="form-group">
                  <label for="step{{item.step}}--{{v.field}}">{{v.title}}</label>
                  <div class="clearfix">
                    <textarea style="width:100%;height:400px;" class="layui-textarea inputJson" name="{{item.step}}[{{v.field}}]" id="step{{item.step}}--{{v.field}}">{{=v.default}}</textarea>
                  </div>
                </div>
                {{#  }else if(v.input_type == 'number'){ }}
                <div class="form-group">
                  <label for="step{{item.step}}--{{v.field}}"><b class="text-pink">{{#  if(v.null == 'no'){ }}*{{#  } }}</b>{{v.title}}</label>
                  <input type="{{v.input_type}}" step="{{=v.value.step}}" class="form-control" placeholder="请输入{{v.title}}" name="{{item.step}}[{{v.field}}]" id="step{{item.step}}--{{v.field}}" value="{{=v.default}}">

                </div>

                {{#  }else if(v.input_type == 'readonly'){ }}
                <div class="form-group">
                  <label for="step{{item.step}}--{{v.field}}"><b class="text-pink">{{#  if(v.null == 'no'){ }}*{{#  } }}</b>{{v.title}}</label>
                  <input type="{{v.input_type}}" readonly class="form-control" placeholder="请输入{{v.title}}" name="{{item.step}}[{{v.field}}]" id="step{{item.step}}--{{v.field}}" value="{{=v.default}}">

                </div>

                {{# }else{ }}
                <div class="form-group">
                  <label for="step{{item.step}}--{{v.field}}"><b class="text-pink">{{#  if(v.null == 'no'){ }}*{{#  } }}</b>{{v.title}}</label>
                  <input type="{{v.input_type}}" class="form-control" placeholder="请输入{{v.title}}" name="{{item.step}}[{{v.field}}]" id="step{{item.step}}--{{v.field}}" value="{{=v.default}}">

                </div>
                {{#  } }}


                {{#  }); }}
              </div>
            </div>
            <!----分步骤表单--->

            {{#  }); }}


          </div>

          <div class="col-xs-12" id="from-button" style="text-align: center;">
            <button type="button" class="from-button btn btn-default" id="upButton" style="display: none;" >上一步</button>
            <button type="button" class="from-button btn btn-info" id="nextButton" lay-filter="nextButton" style="display: none;">下一步</button>
            <button type="button" class="btn btn-primary" lay-submit lay-filter="onsubmit" data-tabindex="0" style="display: none;" id="submitButton">完&nbsp;&nbsp;成</button>
          </div>
        </div>

      </div>
    </div>


  </div>

</div>
</form>
<script type="text/javascript" src="../js/layer/layui.js"></script>
<script>
  ready(function() {

    layui.use(['zhanshop','form', 'zhanshopFrom'], function(){
      var form = layui.form;
      var menuId = parent.layui.zhanshop.getParam('_id');
      const IDNAME = parent.layui.zhanshop.table.idName;
      window.schmas = null;
      layui.zhanshop.view(API_ADDRESS+apiUrlTable+'/'+menuId, '#view', function(data){
        schmas = data;
        layui.zhanshopFrom.render();
        // 表单提交的处理
        //监听提交
        layui.form.on('submit(onsubmit)', function(data){
          window.submitData = data.field;
          delete submitData['select'];
          layui.zhanshopFrom.verification(submitData, function(){
            // 我这里不要走json了
            layui.zhanshop.ajax(API_ADDRESS+apiUrlTable+'/'+menuId, 'POST', submitData, {}, function(res){
              return layui.zhanshop.alert('操作成功', 'success', function(){
                if($("#page-tab", window.parent.document).find('.layui-this').length){
                  $("#page-tab", window.parent.document).find('.layui-this').click();
                  parent.layer.closeAll();
                }else{
                  parent.window.location.reload();
                }
              });
            },function(xhr){
              return layui.zhanshop.alert(xhr.responseJSON[apiMsg] ? xhr.responseJSON[apiMsg] : xhr.statusText, 'danger');
            }, true, apiFromJson);
          });

          return false;
        });
      }, 'POST', {"_method":"addfrom"});
    });

  });
</script>
</body>
</html>
